<?php

namespace app\admin\controller;

use app\model\InsurantModel;
use app\model\PolicyModel;
use think\Request;
use think\Validate;

class Pass extends Base
{
    protected $model;

    public function __construct( )
    {
        parent::__construct();
    }

    /**
     * 列表展示
     * @return \think\response\View
     */
    public function insurant_pass()
    {
        $url = url("Pass/insurantList");
        $this->assign('url',$url);
        return $this->fetch('pass/index');
    }

    /**
     * 列表接口
     */
    public function insurantList()
    {
        $param = $this->request->param();
        $page = isset($param['page']) ? intval($param['page']) : 1;
        $pageSize = isset($param['limit']) ? intval($param['limit']) : 10;
        $arr = ['like'=>'u.username','1'=>'p.policy_num'];
        $where = $this->select_param($arr,$param);
        $where['p.policy_status'] = 4;
        $PolicyModel = new PolicyModel();
        $list =  $PolicyModel->getinsurantListPage($page,$pageSize,$where,false);

        $count =  $PolicyModel->getinsurantListPage(0,0,$where,true);
        return json(['code'=>0,'msg'=>'','count'=>$count,'data'=>$list]);
    }


    /**
     * 列表展示
     * @return \think\response\View
     */
    public function rem_pass()
    {
        $url = url("Pass/remList");
        $this->assign('url',$url);
        return $this->fetch('pass/rem_pass');
    }

    /**
     * 列表接口
     */
    public function remList()
    {
        $param = $this->request->param();
        $page = isset($param['page']) ? intval($param['page']) : 1;
        $pageSize = isset($param['limit']) ? intval($param['limit']) : 10;
        $arr = ['like'=>'p.policy_num'];
        $where = $this->select_param($arr,$param);
        $where['i.status'] = 2 ;
        $InsurantModel = new InsurantModel();
        $list =  $InsurantModel->getinsurantStepListPage($page,$pageSize,$where,false);
        $count =  $InsurantModel->getinsurantStepListPage(0,0,$where,true);
        return json(['code'=>0,'msg'=>'','count'=>$count,'data'=>$list]);
    }


    public function return_rem()
    {
        $param = $this->request->param();
        $this->assign('policy_num',$param['policy_num']);
        return $this->fetch('pass/return_rem');
    }

}